﻿
using IdentityServer4.EntityFramework.Interfaces;
using IdentityServer4.EntityFramework.Stores;
using IdentityServer4.Stores;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ZFY.UMC.Identity.Model.Client;
using ZFY.UMC.API.Service;

namespace ZFY.UMC.Identity.Controllers.Client
{
    public class ClientController : BaseController
    {
        private readonly IConfigurationDbContext _configurationDbContext;

        public ClientController(IConfigurationDbContext configurationDbContext)
        {
            _configurationDbContext = configurationDbContext;
        }
        [HttpGet]
        public async Task<IActionResult> Index(int pageIndex = 1)
        {
            var clients = await _configurationDbContext.Clients
                .Skip((pageIndex - 1) * 8)
                .Select(x=>new ClientViewModel { 
                   ClientName = x.ClientName,
                   ClientUrl = x.ClientUri,
                   LogoUrl = x.LogoUri
                })
                .ToListAsync();

          
            return View(clients);
        }
    }
}
